<?php
//echo 'tes aja'; exit;

    foreach ($getDetail as $row) {
        $vnik 		= 	$row['USRUPD'];
    	$vname 		= 	$row['NAME'];
    	$vorg 		= 	$row['ORG'];
    	$vjob		= 	$row['JOB_POSITION'];
    	$viscard	=	$row['ISCARD'];
    	$vistelp	=	$row['ISTELP'];
    	$vusefor	=	$row['USE_FOR'];
    	$vvendor	=	$row['VENDOR'];
    	$vusername	=	$row['USER_NAME'];
    	$vdtmupd	=	$row['DTMUPD'];
    	$vdesc		=	$row['CTRL_DESCRIPTION'];
    	$vdate1		=	$row['CTRL_DATE_AWAL'];
    	$vdate2		=	$row['CTRL_DATE_AKHIR'];
    	$vtime1		=	$row['CTRL_HOUR_AWAL'];
    	$vtime2		=	$row['CTRL_HOUR_AKHIR'];
    	$vAtasanNik	= $row['CTRL_ATASAN_ID'];
    	$vAtasanName = $row['ATASANNAME'];	
    	
    	$xNik			= $row['CTRL_NIP'];
    	$xName			= $row['NIPNAME'];
    	$xOrg  			= $row['NIPORG'];
    	$xJob  			= $row['NIPJOBPOSITION'];
    }
    
    //var_dump($row1);exit;
    $pKey = '';
    foreach ($getFloor as $row2) {
    	$pKey .= $row['CARD_FLOOR_NAME'].", ";
    }
    $pKey = substr($pKey, 0, -2);
    
    $pTelp = '';
    foreach ($getFloor2 as $row3) {
	   $pTelp .= $row['TELP_EXT_EXT_TYPE'].", ";
    }
    $pTelp = substr($pTelp, 0, -2);
    
    //belum bisa dikerjakan, menunggu session user login
    //if (empty($org)) $org = dbora_getorg($nik);
?>

<script>
    function cancel() {
        $.post("<?= site_url() ?>search_global", function(data) {
            window.location = '<?php echo base_url(); ?>search_global';
        });
    }
    function closeSrnKrjAccSave() {
        $radioChecked='';
        if (document.getElementById("pApprovalY").checked == true){
            $radioChecked = "Y"; 
        }
        else{
            $radioChecked = "N";
        }
        
        $.post("<?= site_url() ?>search_global/closing_reqSave", {
            pCtrlID: $('#pCtrlID').val(),
            pCType: $('#pCType').val(),
            pApproval: $radioChecked 
            //pComment: $('#pComment').val(),
            //pAccesNo: $('#pAccesNo').val()
        },
        function(data) {
            window.location = '<?php echo base_url(); ?>search_global';
        }
        );
    }
</script>


<form id="formarea" role="form" method="post" action="#">
<input type="hidden" value="<?php echo $cRequestNo; ?>" id="pCtrlID" />
<input type="hidden" value="<?php echo $cType; ?>" id="pCType" />
<div class="col-md-offset-0" id="top">
    <div class="col-md-11">
        <div class="panel panel-default">
			<div class="panel-heading">
			<h4 class="panel-title"><b> Request By </b></h4>
			</div>
			<div class="panel-body">
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">NIK</label>
    						<div class="col-md-9"><?php echo $xNik;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Nama</label>
    						<div class="col-md-9"><?php echo $xName;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Departemen</label>
    						<div class="col-md-9"><?php echo $xOrg;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Position</label>
    						<div class="col-md-9"><?php echo $xJob;?></div>
				        </div>
                    </div>                   
                </div>
                
            </div>
        </div>
        
        <div class="panel panel-default">
			<div class="panel-heading">
			<h4 class="panel-title"><b> Request </b></h4>
			</div>
			<div class="panel-body">
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Use For</label>
    						<div class="col-md-9"><?php echo $vusefor;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Vendor Name</label>
    						<div class="col-md-9"><?php echo $vvendor;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Person</label>
    						<div class="col-md-9"><?php echo $vusername;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">ID Card</label>
    						<div class="col-md-9"><?php echo $viscard == 1 ? "Yes" : "No";?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Access Control</label>
    						<div class="col-md-9"><?php echo $pKey;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Line Telp</label>
    						<div class="col-md-9"><?php echo $vistelp == 1 ? "Yes" : "No";?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Line Telp Floor</label>
    						<div class="col-md-9"><?php echo $pTelp;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Jam Pemakaian</label>
    						<div class="col-md-9"><?php echo (!empty($vtime1) || !empty($vtime2)) ? "$vtime1 s/d $vtime2" : "-";?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Periode</label>
    						<div class="col-md-9"><?php echo (!empty($vdate1) || !empty($vdate2)) ? "$vdate1 s/d $vdate2" : "-";?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Tgl Request Order</label>
    						<div class="col-md-9"><?php echo $vdtmupd;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Description</label>
    						<div class="col-md-9"><?php echo nl2br($vdesc);?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Nama Atasan</label>
    						<div class="col-md-9"><?php echo $vAtasanName;?></div>
				        </div>
                    </div>                   
                </div>
                
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Closing Order</label>
    						<div class="col-md-9">
                            <input type="radio" name="radioApp" id="pApprovalY" value="Y"/>Yes
                            <input type="radio" name="radioApp" id="pApprovalN" value="N" checked=""/>No
                            </div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3"></label>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3"></label>
    						<div class="col-sm-2">
                                <button type="button" class="btn btn-primary btn-block" onclick="closeSrnKrjAccSave();">Submit</button>
                            </div>
                            <div class="col-sm-2">
                                <button type="button" class="btn btn-default btn-block" onclick="cancel();" >Cancel</button>
                            </div>
				        </div>
                    </div>                   
                </div>
            </div>
        </div>
    
    </div>
</div>
</form>